<!--新密码设置-->
<template>
    <div class="newPassword">
        <p class="title" v-if="!successLayer">新密码设置</p>
        <div class="rung" v-if="!successLayer">
            <img src="../assets/img/passWordIcon.png">
            <input type="text" placeholder="请输入新密码" v-model="newPassword">
        </div>
        <div class="rung" v-if="!successLayer">
            <img src="../assets/img/passWordIcon.png">
            <input type="text" placeholder="请再次确认新密码" v-model="confirmPassword">
        </div>
        <div class="success" v-if="successLayer">
            <img src="../assets/img/successPass.png">
            <p>密码修改成功</p>
        </div>
        <div class="submit" @click="submit">确认</div>

    </div>
</template>

<script>
    import {Toast} from 'vant';
    import Url from "../untils/configUrl";
    import {post} from "../untils/https"

    export default {
        data() {
            return {
                successLayer: false,
                newPassword: null,
                confirmPassword: null,
                uid: null
            }
        },
        methods: {
            submit() {
                if (this.successLayer) {
                    this.$router.replace("/");
                    return
                }
                if (!this.newPassword) {
                    Toast({
                        duration: 2000,
                        message: '请输入新密码！',
                    });
                    return
                }
                if (!this.confirmPassword) {
                    Toast({
                        duration: 2000,
                        message: '请再次确认新密码！',
                        onClose: function () {
                        }
                    });
                    return
                }
                Toast.loading({
                    mask: true,
                    message: '加载中...',
                    duration: 0
                });
                post(Url.urlConfig.resetPassword, {
                    newPassword: this.newPassword,
                    confirmPassword: this.confirmPassword,
                    uid: this.uid,
                }).then((data) => {
                    Toast.clear();
                    if (data.code === 200) {
                        this.successLayer = true
                    }
                }, () => {
                    Toast.clear();
                })

            }
        },
        created() {
            this.uid = this.$route.query.uid;
        }
    }
</script>

<style scoped lang="less">
    .newPassword {
        width: 100%;
        height: 100%;
        overflow: hidden;

        .title {
            font-size: 48px;
            font-family: PingFangSC-Semibold;
            font-weight: bold;
            color: rgba(29, 30, 44, 1);
            margin: 80px 0 79px 65px;
        }

        .rung {
            display: flex;
            align-items: center;
            width: 100%;
            height: 90px;
            padding-left: 94px;
            box-sizing: border-box;
            background-color: #fff;
            margin-bottom: 30px;

            img {
                width: 35px;
                height: 35px;
                margin-right: 30px;
            }

            .lock {
                width: 43px;
                height: 43px;
                margin-left: 5px;
                margin-right: 20px;
            }

            input {
                display: flex;
                align-items: center;
                width: 500px;
                height: 100%;
                font-size: 28px;

                &::-webkit-input-placeholder {
                    font-size: 28px;
                    font-family: PingFangSC-Regular;
                    font-weight: 400;
                    color: rgba(182, 182, 182, 1);
                }

                &:-ms-input-placeholder {
                    font-size: 28px;
                    font-family: PingFangSC-Regular;
                    font-weight: 400;
                    color: rgba(182, 182, 182, 1);
                }
            }
        }

        .success {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 300px;
            margin: 180px auto 0;

            img {
                width: 200px;
                height: 200px;
                margin-bottom: 31px;
            }

            p {
                font-size: 36px;
                font-family: PingFangSC-Medium;
                font-weight: 500;
                color: rgba(50, 50, 50, 1);
            }
        }

        .submit {
            width: 622px;
            height: 100px;
            background: rgba(98, 125, 241, 1);
            border-radius: 50px;
            font-size: 28px;
            font-family: PingFangSC-Regular;
            font-weight: bold;
            color: rgba(255, 255, 255, 1);
            text-align: center;
            line-height: 100px;
            margin: 80px auto 0;
        }

    }
</style>
